import {
  Controller,
  Get,
  Query,
  Param,
  Post,
  Body,
  UploadedFile,
  UseInterceptors,
} from '@nestjs/common';
import { HelloService } from './hello.service';
import { HelloDto } from './dto/hello.dto';
import { CustomFileUploadInterceptor } from 'src/common/interceptors/file-upload.interceptor';
// import { Hello } from './entites/hello.entity';
@Controller('hello')
export class HelloController {
  constructor(private readonly helloService: HelloService) {}
  /*
    // 使用查询参数获取传入的name ?name=John
    @Get()
    getHello(@Query('name') name: string): { message: string } {
      return { message: this.helloService.getMessage(name) };
    }
    // 使用动态参数获取传入的name /hello/John
    @Get(':name')
    getHello2(@Param('name') name: string): { message: string } {
      return { message: this.helloService.getMessage(name) };
    }
    // 使用请求体获取传入的name
    @Post('add')
    addHello(@Body() body: HelloDto): { message: string } {
      return { message: this.helloService.getMessage(body.name) };
    }

    // 使用文件上传
    @Post('upload')
    @UseInterceptors(CustomFileUploadInterceptor('file'))
    uploadFile(@UploadedFile() file: Express.Multer.File) {
      return this.helloService.uploadFile(file);
    }
  */
  // 获取所有消息
  @Get('all')
  findAll() {
    return this.helloService.findAll();
  }
}
